package com.pb.web.interceptors;

import java.util.Map;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.pb.entity.User;

public class AuthorizationInterceptor extends AbstractInterceptor{

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		//获取session中保持的用户信息
		Map<String,Object> session = invocation.getInvocationContext().getSession();
		User user =(User)session.get("user");
		if (user == null) {
			//如果用户尚未登录，返回到登录页面
			return Action.LOGIN;
		}else {
			//如果用户已经登录，继续执行拦截器和Action
			return invocation.invoke();
		}
	}

}
